package com.zihan.controller;


import com.zihan.domain.dto.AchievementDTO;
import com.zihan.domain.entity.Achievement;
import com.zihan.domain.result.PageResult;
import com.zihan.domain.result.Result;
import com.zihan.domain.vo.AchievementVO;
import com.zihan.service.IAchievementService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 成果表 前端控制器
 * </p>
 *
 * @author zhangzihan
 * @since 2025-10-17
 */
@RestController
@RequestMapping("/achievement")
public class AchievementController {

    @Resource
    private IAchievementService achievementService;

    /**
     * 添加成果
     */
    @PostMapping("/submit")
    public Result<String> add(@RequestBody Achievement achievement) {
        return achievementService.addAchievement(achievement);
    }


    /**
     * 获取当前学生用户成果信息
     */
    @GetMapping("/my-list")
    public Result<PageResult> list(AchievementDTO achievement) {
        return achievementService.getMyList(achievement);
    }


    /**
     * 获取成果详情内容
     */
    @GetMapping("/detail/{id}")
    public Result<AchievementVO> detail(@PathVariable Long id) {
        return achievementService.getDetail(id);
    }

    // 更新成果
    @PutMapping("/update")
    public Result<String> update(@RequestBody Achievement achievement) {
        return achievementService.updateAchievement(achievement);
    }

    // 删除成果
    @DeleteMapping("/delete/{id}")
    public Result<String> delete(@PathVariable Long id) {
        return achievementService.deleteAchievement(id);
    }

    @GetMapping("/teacher-review-list")
    public Result<PageResult> teacherReviewList(AchievementDTO achievement) {
        return achievementService.getTeacherReviewList(achievement);
    }


    @PostMapping("/teacher-review")
    public Result<String> teacherReview(@RequestBody Achievement achievement) {
        return achievementService.teacherReview(achievement);
    }


    /**
     * 获取管理员的成果列表
     */
    @GetMapping("/admin-approval-list")
    public Result<PageResult> adminReviewList(AchievementDTO achievement) {
        return achievementService.getAdminReviewList(achievement);
    }


    /**
     * 管理员审核
     */
    @PostMapping("/admin-approval")
    public Result<String> adminReview(@RequestBody Achievement achievement) {
        return achievementService.adminReview(achievement);
    }
}
